# Lemmas from continuity
LEMMA.
Let $f: I \to R$ be continuous, where $I$ is an interval. For any closed interval $J \subset f(I)$, there exists a closed interval $Q$ where $f(Q)=J$.
PROOF.
If $J$ is a degenerate interval then we are done.
Else, say $J = [f(p) , f(q)]$ where $f(p) < f(q)$, for some $p,q \in I$. Suppose the case that $p < q$.
Define $s$ to be the smallest element in $[p,q]$ where $f(s) = f(q)$.
This smallest element exists since we have nonempty bounded set $S = \set{t \in [p,q],f(t)=f(q)}$, so $s =\inf S$ exists in $[p,q]$ as $[p,q]$ is closed. We have $f(s) = f(q)$ because there exists a sequence $s_{n} \in S$ where $s_{n} \to s$, and as $f$ continuous, $f(s_{n})=f(q) \to f(s)$, hence $f(s)=f(q)$.
Similarly, we can take $r$ to be the largest element in $[p,q]$ where $f(r) = f(p)$.
Now we claim, $Q =[r,s]$ is the desired interval where $f([r,s]) = J$.
Suppose to the contrary that there exists some $t$ where $r < t < s$ where $f(t) \notin J$. Say $f(t) > f(q) = f(s)$. Then as $f(t) > f(q) > f(p)$, by intermediate value theorem, we have some $s' \in (t,s)$ such that $f(s') = f(q)$. Then we have $s' < s$ and $s' \in [p,q]$ such that $f(s') = f(q)$, contradicting the minimality of $s$. Hence $f(t) \in f(t) \in J$.
The other cases are analogous. $\blacksquare$